/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author laz
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface HistoryOrders extends BasicModel<HistoryOrders> {
  parentId?: number; // 父订单ID
  shopId?: number; // 店铺ID
  productId?: number; // 商品ID
  orderFormid?: string; // 订单来源标识
  buyerUserId?: number; // 购买用户ID
  price?: number; // 订单价格
  state?: number; // 订单状态 (例如: 0-待付款 1-待发货 2-待收货 3-已完成 4-已关闭)
  createTime?: string; // 下单时间 (格式: 'yyyy-MM-dd HH:mm:ss')
  shopName?: string; // 店铺名称
  productName?: string; // 商品名称
}

export const historyOrdersList = (params?: HistoryOrders | any) =>
  defHttp.get<HistoryOrders>({ url: adminPath + '/information/historyOrders/list', params });

export const historyOrdersListData = (params?: HistoryOrders | any) =>
  defHttp.post<Page<HistoryOrders>>({
    url: adminPath + '/information/historyOrders/listData',
    params,
  });

export const historyOrdersForm = (params?: HistoryOrders | any) =>
  defHttp.get<HistoryOrders>({ url: adminPath + '/information/historyOrders/form', params });

export const historyOrdersSave = (params?: any, data?: HistoryOrders | any) =>
  defHttp.postJson<HistoryOrders>({
    url: adminPath + '/information/historyOrders/save',
    params,
    data,
  });

export const historyOrdersDelete = (params?: HistoryOrders | any) =>
  defHttp.get<HistoryOrders>({ url: adminPath + '/information/historyOrders/delete', params });

// export const historyOrdersInsert = (params?: any, data?: HistoryOrders | any) =>
//   defHttp.postJson<HistoryOrders>({
//     url: '/api-hyd/import/hyd',
//     data,
//   });

export const historyOrdersInsert = (data?: HistoryOrders[] | any) =>
  defHttp.postJson<HistoryOrders>(
    {
      // 告诉请求库，本次请求的基础URL是服务器根目录 '/'，
      // 这会有效地忽略掉默认的 '/js' 前缀。
      baseURL: '/',
      // 现在提供指向代理的完整路径
      url: '/api-hyd/import/hyd',
      data,
    },
    {
      joinPrefix: false, // 在这里关闭前缀拼接
    },
  );

export const historyOrdersUpdate = (data?: HistoryOrders[] | any) =>
  defHttp.postJson<HistoryOrders>(
    {
      // 告诉请求库，本次请求的基础URL是服务器根目录 '/'，
      // 这会有效地忽略掉默认的 '/js' 前缀。
      baseURL: '/',
      // 现在提供指向代理的完整路径
      url: '/api-hyd/import/zy_ylj',
      data,
    },
    {
      joinPrefix: false, // 在这里关闭前缀拼接
    },
  );

export const getProducts = (data?: HistoryOrders[] | any) =>
  defHttp.postJson<HistoryOrders>(
    {
      // 告诉请求库，本次请求的基础URL是服务器根目录 '/'，
      // 这会有效地忽略掉默认的 '/js' 前缀。
      baseURL: '/',
      // 现在提供指向代理的完整路径
      url: '/api-hyd/canvas/getAll',
      data,
    },
    {
      joinPrefix: false, // 在这里关闭前缀拼接
    },
  );
